package ain.standard;

import util.Vector;
import environment.Pitch;
import environment.player.Player;

public class StandardKickAntibody extends StandardAbstractAntibody
{
	private static int ID = 2;
	
	public StandardKickAntibody(Player player, Pitch pitch)
	{
		super(player, pitch);
	}
	
	public void execute()
	{
		// kick straight ahead. just for testing purposes
		
		// find target
		double xValue = player.getOpponentGoal().getX();
		double yValue = player.getPosition().getY();
		Vector target = new Vector(xValue, yValue);
		
		// determine direction & impulse
		Vector direction = Vector.substract(target, player.getPosition());
		direction.normalize();
		direction.multiply(player.getMaxKickImpulse() / 3);
		
		// kick
		player.kick(direction);
	}
	
	protected double distBallRatioValue(double ratio)
	{
		return (ratio <= 2) ? 1 - (ratio / 2) : 0;
	}
	
	protected double distBallGoalValue(double zoneNumber)
	{
		if (zoneNumber <= (1.0 / 3) * 5)
		{
			return zoneNumber / ((1.0 / 3) * 5);
		}
		if (zoneNumber <= (2.0 / 3) * 5)
		{
			return 1 - (zoneNumber - ((1.0 / 3) * 5)) / ((1.0 / 3) * 5);
		}
		
		return 0;
	}
	
	protected double imprDistBallGoalValue(double zoneNumber)
	{
		if (zoneNumber <= (1 + (4.0/3.0)))
		{
			return (zoneNumber - 1) / (4.0/3.0);
		}
		if (zoneNumber <= (1 + (8.0/3.0)))
		{
			return 1 - (zoneNumber - (1 + (4.0/3.0))) / (4.0/3.0);
		}
		
		return 0;
	}
	
	protected double distBallPlayerValue(double distance)
	{
		if (distance <= FAR_RADIUS)
		{
			return 1 - (distance / FAR_RADIUS);
		}
		else return 0;
	}
	
	public int getID()
	{
		return ID;
	}
	
	public String toString()
	{
		return "Kick";
	}
}
